home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / telecom / 16 / pascal / shell.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1986-05-13  |  21.9 KB  |  705 lines

  1. Program shell;
  2.  
  3. CONST
  4.         (*$I gemconst.pas *)              (* Include all the GEM constants *)
  5.         Desk_Title      =       3;      (* Value for Desk menu item      *)
  6.         files           =       0;      (* File attribute for a file     *)
  7.         volumes         =       8;      (* File attribute for the volume *)
  8.         folders         =       16;     (* File attribute for a folder   *)
  9.  
  10. TYPE
  11.  
  12.         (*$I gemtype.pas *)
  13.  
  14. VAR
  15.         wind_title      :       Window_Title;   (* Window name           *)
  16.  
  17.         msg             :       Message_Buffer; (* GEM message buffer    *)
  18.  
  19.         a_menu          :       Menu_Ptr;       (* Value for our menu    *)
  20.  
  21.         Info_Box        :       Dialog_Ptr;     (* Need this for Dialog Box *)
  22.  
  23.         out_char        :       char;           (* Used to display characters
  24.                                                   to the screen         *)
  25.  
  26.         title1,  (*  -                                                   *)
  27.         title2,  (*   |                                                  *)
  28.         title3,  (*   |- Variables for our 5 menu titles                 *)
  29.         title4,  (*   |                                                  *)
  30.         title5,  (*  -                                                   *)
  31.         item11,  (*  -                                                   *)
  32.         item12,  (*   |                                                  *)
  33.         item13,  (*   |                                                  *)
  34.         item21,  (*   |                                                  *)
  35.         item22,  (*   |                                                  *)
  36.         item23,  (*   |                                                  *)
  37.         item31,  (*   |                                                  *)
  38.         item32,  (*   |- Variables for all menu items                    *)
  39.         item33,  (*   |                                                  *)
  40.         item41,  (*   |                                                  *)
  41.         item42,  (*   |                                                  *)
  42.         item43,  (*   |                                                  *)
  43.         item51,  (*   |                                                  *)
  44.         item52,  (*   |                                                  *)
  45.         item53,  (*  -                                                   *)
  46.         sf,
  47.         info_item,
  48.         ok_button,
  49.         button,
  50.         dummy,
  51.         event_val,
  52.         windtype,
  53.         big_window,
  54.         event,
  55.         what_key, (* Key pressed and processed *)
  56.         key_lo,   (* Low order byte of key     *)
  57.         key_hi,   (* High order byte of key    *)
  58.         hx,       (* Hold the maximum screen values for WM_Fulled message *)
  59.         hy,
  60.         hw,
  61.         hh,
  62.         xm,       (* Screen work area after we open the window *)
  63.         ym,
  64.         wm,
  65.         hm,
  66.         cw,       (* Character size, width, height and the box size *)
  67.         ch,
  68.         bw,
  69.         bh,
  70.         cur_x,    (* Cursor position for displaying to the screen *)
  71.         cur_y,
  72.         zeron,    (* Device zero is the printer                   *)
  73.         escn,
  74.         x,
  75.         y               :       integer;
  76.  
  77.         (*$I gemsubs.pas *)      (* Include all GEM subroutines *)
  78.  
  79. Procedure bconout(dev, c:integer);   (* Put a character to a device *)
  80. BIOS(3);                             (* Necessary for esc character *)
  81.  
  82. Function Rect_Intersect(x1,y1,w1,h1:integer;VAR x2,y2,w2,h2:integer):boolean;
  83. EXTERNAL;
  84.  
  85. Procedure build_screen;
  86. begin
  87.  
  88.         (* Your code goes here for what you may want to display on the
  89.           screen. This would have to be saved in order to do a redraw
  90.           after a message from GEM.                                     *)
  91.  
  92. end;
  93.  
  94. (* The following routine will do a redraw of our window after something
  95.   has been placed over it. It works extremely fast, because it will
  96.   only draw the clipped area, and not the entire screen.                *)
  97.  
  98. Procedure Do_Redraw(handle, x0, y0, w0, h0 : integer);
  99. VAR
  100.   x, y, w, h :integer;
  101.  
  102. begin
  103.   Begin_Update;
  104.   Hide_Mouse;
  105.   First_Rect(handle, x, y, w, h);
  106.   While (w <> 0) and (h <> 0) do
  107.     begin
  108.       If Rect_Intersect( x0, y0, w0, h0, x, y, w, h) then
  109.         begin
  110.           Set_Clip(x, y, w, h);
  111.           Paint_Color(white);
  112.           Paint_Rect(x, y, w, h);
  113.           build_screen;
  114.         end;
  115.       Next_Rect(handle, x, y, w, h);
  116.     end;
  117.   Show_Mouse;
  118.   Set_Clip(xm, ym, wm, hm);
  119.   End_Update;
  120. end;
  121.  
  122. (* If we get a message from GEM that our window is now to be the front
  123.   window, then this routine will bring it to the front.                 *)
  124.  
  125. Procedure Do_Topped;
  126. begin
  127.   Set_Clip(xm, ym, wm, hm);
  128.   Bring_To_Front(big_window);
  129. end;
  130.  
  131. (* This routine will only clear and redraw a blank window. If you have
  132.   already placed something on the screen, then you will need to save
  133.   it somewhere if you wish to see it after a redraw or other type of
  134.   GEM message.                                                          *)
  135.  
  136. Procedure draw_wind;
  137. begin
  138.   Hide_Mouse;
  139.   Work_Rect(big_window,xm,ym,wm,hm);
  140.   Set_Clip(xm,ym,wm,hm);
  141.   Set_Color(white,1000,1000,1000);
  142.   Paint_Rect(xm,ym,wm,hm);
  143.   Show_Mouse;
  144.   cur_x := xm;
  145.   cur_y := ym + ch;
  146. end;
  147.  
  148. (* The following routines process menu item selection. Each one now only
  149.   performs an ALERT box, but any type of code can be added.             *)
  150.  
  151. Procedure item11_proc;
  152. begin
  153.   dummy := Do_Alert('[1][ITEM| 1 - 1][ OK ]',0);
  154. end;
  155.  
  156. Procedure item12_proc;
  157. begin
  158.   dummy := Do_Alert('[1][ITEM| 1 - 2][ OK ]',0);
  159. end;
  160.  
  161. Procedure item13_proc;
  162. begin
  163.   dummy := Do_Alert('[1][ITEM| 1 - 3][ OK ]',0);
  164. end;
  165.  
  166. Procedure item21_proc;
  167. begin
  168.   dummy := Do_Alert('[1][ITEM| 2 - 1][ OK ]',0);
  169. end;
  170.  
  171. Procedure item22_proc;
  172. begin
  173.   dummy := Do_Alert('[1][ITEM| 2 - 2][ OK ]',0);
  174. end;
  175.  
  176. Procedure item23_proc;
  177. begin
  178.   dummy := Do_Alert('[1][ITEM| 2 - 3][ OK ]',0);
  179. end;
  180.  
  181. Procedure item31_proc;
  182. begin
  183.   dummy := Do_Alert('[1][ITEM| 3 - 1][ OK ]',0);
  184. end;
  185.  
  186. Procedure item32_proc;
  187. begin
  188.   dummy := Do_Alert('[1][ITEM| 3 - 2][ OK ]',0);
  189. end;
  190.  
  191. Procedure item33_proc;
  192. begin
  193.   dummy := Do_Alert('[1][ITEM| 3 - 3][ OK ]',0);
  194. end;
  195.  
  196. Procedure item41_proc;
  197. begin
  198.   dummy := Do_Alert('[1][ITEM| 4 - 1][ OK ]',0);
  199. end;
  200.  
  201. Procedure item42_proc;
  202. begin
  203.   dummy := Do_Alert('[1][ITEM| 4 - 2][ OK ]',0);
  204. end;
  205.  
  206. Procedure item43_proc;
  207. begin
  208.   dummy := Do_Alert('[1][ITEM| 4 - 3][ OK ]',0);
  209. end;
  210.  
  211. Procedure item51_proc;
  212. begin
  213.   dummy := Do_Alert('[1][ITEM| 5 - 1][ OK ]',0);
  214. end;
  215.  
  216. Procedure item52_proc;
  217. begin
  218.   dummy := Do_Alert('[1][ITEM| 5 - 2][ OK ]',0);
  219. end;
  220.  
  221. Procedure item53_proc;
  222. begin
  223.   dummy := Do_Alert('[1][ITEM| 5 - 3][ OK ]',0);
  224. end;
  225.  
  226. (* Here is where we find out which item is selected from the titles      *)
  227.  
  228. Procedure title1_proc;
  229. begin
  230.   if msg[4] = item11 then
  231.     item11_proc
  232.   ELSE if msg[4] = item12 then
  233.     item12_proc
  234.   ELSE if msg[4] = item13 then
  235.     item13_proc;
  236.   Menu_Normal(a_menu,title1);
  237. end;
  238.  
  239. Procedure title2_proc;
  240. begin
  241.   if msg[4] = item21 then
  242.     item21_proc
  243.   ELSE if msg[4] = item22 then
  244.     item22_proc
  245.   ELSE if msg[4] = item23 then
  246.     item23_proc;
  247.   Menu_Normal(a_menu,title2);
  248. end;
  249.  
  250. Procedure title3_proc;
  251. begin
  252.   if msg[4] = item31 then
  253.     item31_proc
  254.   ELSE if msg[4] = item32 then
  255.     item32_proc
  256.   ELSE if msg[4] = item33 then
  257.     item33_proc;
  258.   Menu_Normal(a_menu,title3);
  259. end;
  260.  
  261. Procedure title4_proc;
  262. begin
  263.   if msg[4] = item41 then
  264.     item41_proc
  265.   ELSE if msg[4] = item42 then
  266.     item42_proc
  267.   ELSE if msg[4] = item43 then
  268.     item43_proc;
  269.   Menu_Normal(a_menu,title4);
  270. end;
  271.  
  272. Procedure title5_proc;
  273. begin
  274.   if msg[4] = item51 then
  275.     item51_proc
  276.   ELSE if msg[4] = item52 then
  277.     item52_proc
  278.   ELSE if msg[4] = item53 then
  279.     item53_proc;
  280.   Menu_Normal(a_menu,title5);
  281. end;
  282.  
  283. (* So you want to build a DIALOG BOX. Here's how you do it               *)
  284.  
  285. Procedure infodial;
  286. begin
  287.   sf := System_Font;
  288.   Info_Box := New_Dialog(15,0,0,40,18);
  289.   info_item := Add_DItem(Info_Box,G_Text,None,2,1,36,1,0,$1180);
  290.   Set_DText(Info_Box,info_item,'Pascal Shell',sf,TE_Center);
  291.   info_item := Add_DItem(Info_Box,G_Text,None,2,3,36,1,0,$1180);
  292.   Set_DText(Info_Box,info_item,'by F.P. Nagle',sf,TE_Center);
  293.   info_item := Add_DItem(Info_Box,G_Text,None,2,5,36,1,0,$1180);
  294.   Set_DText(Info_Box,info_item,'Copyright (c) 1986',sf,TE_Center);
  295.   info_item := Add_DItem(Info_Box,G_Text,None,2,9,36,1,0,$1180);
  296.   Set_DText(Info_Box,info_item,'Portions of this program',
  297.               sf,TE_Center);
  298.   info_item := Add_DItem(Info_Box,G_Text,None,2,11,36,1,0,$1180);
  299.   Set_DText(Info_Box,info_item,'Copyright (c) 1986 OSS & CCD',
  300.               sf,TE_Center);
  301.   info_item := Add_DItem(Info_Box,G_Text,None,2,13,36,1,0,$1180);
  302.   Set_DText(Info_Box,info_item,'Used by permission of OSS.',
  303.               sf,TE_Center);
  304.   ok_button := Add_DItem(Info_Box,G_Button,Selectable|Exit_Btn|Default,
  305.               15,15,8,2,2,$1180);
  306.   Set_DText(Info_Box,ok_button,'OK',sf,TE_Center);
  307.   Center_Dialog(Info_Box);
  308.   button := Do_Dialog(Info_Box,0);
  309.   End_Dialog(Info_Box);
  310.   Menu_Normal(a_menu,Desk_Title);
  311. end;
  312.  
  313. (* A menu item has been selected, here we find which one.                *)
  314.  
  315. Procedure menu_proc;
  316. begin
  317.   If msg[3] = title1 then
  318.     title1_proc
  319.   ELSE if msg[3] = title2 then
  320.     title2_proc
  321.   ELSE if msg[3] = title3 then
  322.     title3_proc
  323.   ELSE if msg[3] = title4 then
  324.     title4_proc
  325.   ELSE if msg[3] = title5 then
  326.     title5_proc
  327.   ELSE if msg[3] = Desk_Title then
  328.     infodial;
  329. end;
  330.  
  331. Procedure blnk_wind;
  332. begin
  333. end;
  334.  
  335. (* GEM has told us that the window was moved, so we must redraw it with
  336.   the correct NEW size.                                                 *)
  337.  
  338. Procedure move_wind;
  339. begin
  340.   Set_WSize(big_window,msg[4],msg[5],msg[6],msg[7]);
  341.   draw_wind;
  342. end;
  343.  
  344. (* GEM has told us that the window has been re-sized, so we need to redraw
  345.   the NEW size window.                                                  *)
  346.  
  347. Procedure size_wind;
  348. begin
  349.   Set_WSize(big_window,msg[4],msg[5],msg[6],msg[7]);
  350.   draw_wind;
  351. end;
  352.  
  353. (* GEM has told us to fill the screen with this window. Note we saved the
  354.   maximum size in hx, hy, hw, hh when we opened the window initially.   *)
  355.  
  356. Procedure full_wind;
  357. begin
  358.   xm := hx;
  359.   ym := hy;
  360.   wm := hw;
  361.   hm := hh;
  362.   Set_WSize(big_window,hx,hy,hw,hh);
  363.   draw_wind;
  364. end;
  365.  
  366. (* Here's how to draw a "cursor" on the screen.  It's only a line!       *)
  367.  
  368. Procedure linex;
  369. begin
  370.   Line(cur_x + 2, cur_y - (ch - 3), cur_x + 2, cur_y);
  371. end;
  372.  
  373. (* Here's how to position the "cursor" on the screen.                    *)
  374.  
  375. Procedure pos_cursor;
  376. begin
  377.   cur_x := cur_x + cw;
  378.   If cur_x > (xm + wm) - cw then
  379.     begin
  380.     cur_x := xm;
  381.     cur_y := cur_y + ch;
  382.     If cur_y > (hm + ym) then
  383.       begin
  384.       cur_y := ym + ch;
  385.       draw_wind;
  386.       end
  387.     end;
  388.   linex;
  389. end;
  390.  
  391.         (* The only way to display text on the screen under GEM is to
  392.           draw the string. We have saved the character value from the
  393.           key pressed, so here we Draw_String (just one character) to
  394.           the screen. cur_x and cur_y are the cursor position, and
  395.           out_char is the value to be drawn.                            *)
  396.  
  397. Procedure disp_it;
  398. begin
  399.   Draw_String(cur_x,cur_y,out_char);
  400. end;
  401.  
  402.         (* Here we change the integer value of the key pressed into a
  403.           character which can be used by the Draw_String command. Before
  404.           doing anything to the screen though, we Hide_Mouse so we don't
  405.           lose part of what we want to show. After we get done, we
  406.           Show_Mouse again.                                             *)
  407.  
  408. Procedure disp_char;
  409. begin
  410.   Hide_Mouse;
  411.   out_char := chr(key_lo);
  412.   disp_it;
  413.   pos_cursor;
  414.   Show_Mouse;
  415. end;
  416.  
  417.         (* Because we are Drawing to the screen, if a back space is
  418.           entered, we need to erase the cursor (line) and move back
  419.           one, and draw a space to the screen. We also need to check
  420.           if the cursor is at the far left already. If so, we can't
  421.           go back any further on this line, so position it at the
  422.           beginning of the current line. You could also add code to
  423.           move UP a line and continue back spacing if desired. This
  424.           is only a demo, so we cut it short here.                      *)
  425.  
  426.  
  427. Procedure back_space;
  428. begin
  429.   Hide_Mouse;
  430.   out_char := chr(32);
  431.   disp_it;
  432.   cur_x := cur_x - cw;
  433.   if cur_x < xm then
  434.     cur_x := xm;
  435.   disp_it;
  436.   linex;
  437.   Show_Mouse;
  438. end;
  439.  
  440.         (* We received a carriage return (ENTER), so we need to erase
  441.           the cursor (line) on the current line. By making the cur_x
  442.           position off the right side of the screen, we can use the
  443.           pos_cursor routine to determine the new line position.        *)
  444.  
  445. Procedure carr_return;
  446. begin
  447.   Hide_Mouse;
  448.   out_char := chr(32);
  449.   disp_it;
  450.   cur_x := xm + wm + cw;
  451.   pos_cursor;
  452.   Show_Mouse;
  453. end;
  454.  
  455. Procedure esc_char;
  456. begin
  457.  
  458. (* To actually send the escape character to any output you
  459.   need to use BIOS(3) since GEM will "swallow" all escape
  460.   characters                                               *)
  461.  
  462. (* bconout(zeron,escn);                                     *)
  463.  
  464. end;
  465.  
  466. Procedure not_used;
  467. begin
  468.  
  469. (* This program doesn't use these particular keys, but that
  470.   does not mean that they aren't available to you for your
  471.   own usage.  Just  define the  routine  that you  need to
  472.   handle your particular needs.                            *)
  473.  
  474. end;
  475.  
  476.         (* Here we check what value we received from the key pressed.
  477.           I only show a check of the low value, not the entire 16
  478.           bit value. In order to determine the use of Function keys
  479.           and the special Help/Undo etc. keys, you would have to check
  480.           the high value also, or use the full integer value.           *)
  481.  
  482. Procedure check_key;
  483. begin
  484.   CASE key_lo of
  485.     32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,
  486.     52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,
  487.     72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,
  488.     92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,
  489.     109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,
  490.     124,125,126,127             :       disp_char;
  491.     8                           :       back_space;
  492.     13                          :       carr_return;
  493.     27                          :       esc_char;
  494.     0,1,2,3,4,5,6,7,9,10,11,12,14,15,16,17,18,19,20,21,22,23,24,
  495.     25,26,28,29,30,31           :       not_used;
  496.   END;
  497. end;
  498.  
  499.         (* Here we break the 16 bit integer value into two parts, the
  500.           high and low values. Since this is a demo, we are only
  501.           checking for normal ASCII values, excluding Function keys etc.*)
  502.  
  503. Procedure key_process;
  504. begin
  505.   key_lo := what_key & $00FF;
  506.   key_hi := what_key & $FF00;
  507.   key_hi := ShR(key_hi,8);
  508.   check_key;
  509.  
  510. end;
  511.  
  512.         (* Once we have received a message from GEM it is up to your
  513.           program to determine just what to do with it. This routine
  514.           checks the most used messages, and performs a simple routine
  515.           within the program to handle each type of message.            *)
  516.  
  517. Procedure msg_process;
  518. begin
  519.   Case msg[0] of
  520.         MN_Selected     :  If Front_Window = big_window then
  521.                                 menu_proc;
  522.  
  523.         WM_Sized        :  If Front_Window = big_window then
  524.                                 size_wind;
  525.  
  526.         WM_Fulled       :  If Front_Window = big_window then
  527.                                 full_wind;
  528.  
  529.         WM_Moved        :  If Front_Window = big_window then
  530.                                 move_wind;
  531.  
  532.         WM_Redraw       :  If msg[3] = big_window then
  533.           Do_Redraw(msg[3],msg[4],msg[5],msg[6],msg[7]);
  534.  
  535.         WM_Topped       :  Do_Topped;
  536.  
  537.   end;
  538.  
  539. end;
  540.  
  541.         (* This is the heart of the program. This event routine is
  542.           repeated over and over until a WM_Closed message is
  543.           received. If the window is closed, the program ends. You
  544.           could also use a QUIT command in one of your menus, and
  545.           force a closed message to cause the program to end.           *)
  546.  
  547. Procedure event_rtn;
  548. begin
  549.   event := Get_Event(event_val,
  550.                      0,0,0,             (* No button goodies     *)
  551.                      0,                 (* No timer              *)
  552.                      False,0,0,0,0,     (* No mouse rects        *)
  553.                      False,0,0,0,0,
  554.                      msg,
  555.                      what_key,          (* Key pressed           *)
  556.                      dummy,dummy,       (* Not used              *)
  557.                      dummy,dummy,
  558.                      dummy
  559.                      );
  560.  
  561.   If (event & E_Message) <> 0 then
  562.     msg_process;
  563.  
  564.   If (event & E_Keyboard) <> 0 then
  565.     key_process;
  566.  
  567. end;
  568.  
  569.         (* This is a demonstratin of how to create your own menu. Variables
  570.           could be of any integer type, so an array would work. I just
  571.           found it simpler to identify each one uniquely.               *)
  572.  
  573. Procedure build_menu;
  574. begin
  575.   a_menu := New_Menu(30,'Pascal Shell');
  576.  
  577.   title1 := Add_MTitle(a_menu,' Title 1 ');
  578.   title2 := Add_MTitle(a_menu,' Title 2 ');
  579.   title3 := Add_MTitle(a_menu,' Title 3 ');
  580.   title4 := Add_MTitle(a_menu,' Title 4 ');
  581.   title5 := Add_MTitle(a_menu,' Title 5 ');
  582.  
  583.   item11 := Add_MItem(a_menu,title1,'  Item 1-1 ');
  584.   item12 := Add_MItem(a_menu,title1,'  Item 1-2 ');
  585.   item13 := Add_MItem(a_menu,title1,'  Item 1-3 ');
  586.  
  587.   item21 := Add_MItem(a_menu,title2,'  Item 2-1 ');
  588.   item22 := Add_MItem(a_menu,title2,'  Item 2-2 ');
  589.   item23 := Add_MItem(a_menu,title2,'  Item 2-3 ');
  590.  
  591.   item31 := Add_MItem(a_menu,title3,'  Item 3-1 ');
  592.   item32 := Add_MItem(a_menu,title3,'  Item 3-2 ');
  593.   item33 := Add_MItem(a_menu,title3,'  Item 3-3 ');
  594.  
  595.   item41 := Add_MItem(a_menu,title4,'  Item 4-1 ');
  596.   item42 := Add_MItem(a_menu,title4,'  Item 4-2 ');
  597.   item43 := Add_MItem(a_menu,title4,'  Item 4-3 ');
  598.  
  599.   item51 := Add_MItem(a_menu,title5,'  Item 5-1 ');
  600.   item52 := Add_MItem(a_menu,title5,'  Item 5-2 ');
  601.   item53 := Add_MItem(a_menu,title5,'  Item 5-3 ');
  602.  
  603.   Draw_Menu(a_menu);
  604. end;
  605.  
  606.         (* Just an alert box at the very beginning of the program.       *)
  607.  
  608. Procedure show_progname;
  609. begin
  610.   dummy := Do_Alert('[1][SHELL.PAS|Version 1.0|by F.P.Nagle][ OK ]',0);
  611. end;
  612.  
  613.         (* I always set up at least one initialize procedure in my programs
  614.           which is always called once. This sets the initial values I
  615.           need for titles, etc. Don't rely on ANY compiler to initialize
  616.           your values for you. Play it safe and do it yourself!         *)
  617.  
  618. Procedure init;
  619. begin
  620.   zeron         := 0;
  621.   escn          := 27;
  622.   wind_title    := 'Pascal Program Shell';
  623.   windtype      := G_Name | G_Close | G_Move | G_Size | G_Full;
  624.   event_val     := E_Message | E_Keyboard;
  625.  
  626.   Text_Style(Normal);
  627.   Sys_Font_Size(cw,ch,bw,bh);
  628. end;
  629.  
  630.         (* This procedure creates and opens YOUR program window!         *)
  631.  
  632. Procedure open_wind;
  633. begin
  634.   big_window := New_Window(windtype,wind_title,0,0,0,0);
  635.   Open_Window(big_window,0,0,0,0);
  636.   Work_Rect(0,hx,hy,hw,hh);    (* Here we save the full size for later use *)
  637.   Work_Rect(big_window,xm,ym,wm,hm);  (* This is the screen work size *)
  638.   cur_x := xm;                 (* Initialize cursor positions         *)
  639.   cur_y := ym + ch;
  640.   blnk_wind;
  641. end;
  642.  
  643.         (* Every program normally has some cleanup to do when the program
  644.           ends. This is my End Of Program (eop) processing. Close the
  645.           window, delete OUR menu etc.                                  *)
  646.  
  647. Procedure eop_processing;
  648. begin
  649.   Close_Window(big_window);
  650.   Delete_Window(big_window);
  651.   Erase_Menu(a_menu);
  652.   Delete_Menu(a_menu);
  653. end;
  654.  
  655.         (* This is the main program. We initialize GEM and check that we
  656.           can run. Init_Mouse will always eliminate any Hides we may have
  657.           remaining from previous programs. It will ALWAYS bring the mouse
  658.           into view. Once we know the status of the mouse we can then
  659.           HIDE it within our program. The clear screen command paints a
  660.           white screen for our program. Just a simple way to give us a
  661.           clean slate to begin with. We then execute a series of procedures
  662.           to set up our program. The repeat within this is the main LOOP
  663.           to continually check for events. When the event is to close the
  664.           window, then we are DONE! The End Of Program processing will
  665.           actually Close and Delete our Window and Menus.               *)
  666.  
  667. BEGIN
  668.         If Init_Gem >= 0 then
  669.         begin
  670.                 Init_Mouse;
  671.                 Hide_Mouse;
  672.                 Clear_Screen;
  673.                 build_menu;
  674.                 show_progname;
  675.                 init;
  676.                 open_wind;
  677.                 Show_Mouse;
  678.                 Repeat
  679.                   event_rtn
  680.                 Until msg[0] = WM_Closed;
  681.                 eop_processing;
  682.         end;
  683.  
  684.         (* After having used Personal Pascal on a few packages about to
  685.           be released, I felt that the information I had gained could
  686.           be helpful to others in creating GEM applications for the
  687.           520/1040 ST. This SHELL can be expanded into a multitude of
  688.           applications. If you develop a new idea based on this, and
  689.           are looking for ways of distributing it, I can be reached at
  690.           the following:
  691.  
  692.           Frank P. Nagle
  693.           38346 Logan Drive
  694.           Fremont, CA 94536-5901
  695.           Answering machine (415) 791-5461
  696.           MCI Mail - FNAGLE
  697.           Compuserve - 70505,577
  698.           Delphi - FRANKN
  699.           GEnie - F.NAGLE
  700.  
  701.           Good luck with your Personal Pascal work!                     *)
  702.  
  703. end.
  704.  
  705. ♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪♪